<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <title></title>
    <script th:src="@{/layer/JQuery/jquery-3.1.1.min.js}"></script>
    <script th:src="@{/layer/layer/layer.js}"></script>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}"/>
    <script th:src="@{/layui/layui.js}"></script>

    <style>
        .layui-input-block {
            margin-right: 500px;
        }
    </style>
</head>

<body>
<form class="layui-form" th:action="@{/catalog}" method="post">
    <input type="hidden" name="_method" value="put"/>
    <input type="hidden" name="cid" th:value="${catalog.cid}">

    <div class="layui-form-item" style="margin-top: 10px">
        <label class="layui-form-label">二级目录</label>
        <div class="layui-input-block">
            <input type="text" id="cname" name="cname" th:value="${catalog.cname}" required lay-verify="required" autocomplete="off"
                   class="layui-input" maxlength="20">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">所属一级目录</label>
        <div class="layui-input-block">
            <input type="text" id="cmemo" name="cmemo" lay-verify="required" autocomplete="off"
                   class="layui-input" maxlength="20" th:value="${catalog.cmemo}">
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" id="modifybutton" lay-submit="" lay-filter="demo">修改</button>
            <a th:href="@{/catalogs}">
                <input type="button" class="layui-btn layui-btn-primary" value="返回" style="margin-left: 9px;"></input>
            </a>
        </div>
    </div>
</form>

<script>
    layui.use('form', function () {
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function (data) {
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });

    $("#cname").blur(function () {
        var temp = $("#cname").val();
        if(temp.replace(/[ ]/g, '')==''){
            $("#cname").val("")
        }
    });

    $("#cmemo").blur(function () {
        var temp = $("#cmemo").val();
        if(temp.replace(/[ ]/g, '')==''){
            $("#cmemo").val("")
        }
    });
</script>
</body>

</html>